package LC;

import java.util.ArrayList;
import java.util.List;
import java.util.Stack;

/**
 * @ClassName LC94
 * @Description: TODO
 * @Author hl
 * @Date 2020/5/31
 * @Version V1.0
 **/
public class LC94 {

    //二叉树的中序遍历
    public List<Integer> inorderTraversal(TreeNode root) {
        ArrayList<Integer> list=new ArrayList<>();
        if(root==null){
            return  list;
        }
        Stack<TreeNode> stack=new Stack<>();
        while(root!=null||!stack.isEmpty()){
            while(root!=null){
                stack.push(root);
                root=root.left;
            }
            TreeNode node=stack.pop();
            list.add(node.val);
            root=node.right;
        }
        return  list;
    }

}
